package FourWeek;

import java.util.Arrays;

public class charupaixu {
    public static void main(String[] args) {
        int[]arr={12,13,6,17,21,10};
        System.out.println("Arrays.toString(arr)"+Arrays.toString(arr));
        inserSort(arr);
        System.out.println("Arrays.toString(arr)"+Arrays.toString(arr));
    }
    public static void inserSort(int[]a){
        int r;
        for (int i = 0; i < a.length; i++) {//从第0个数逐个遍历数组元素
            for (int j = i; j >0; j--) {
                if (a[j-1]>a[j]){
                    r=a[j-1];
                    a[j-1]=a[j];
                    a[j]=r;
                }
            }
        }
    }
}
